//
//  main.m
//  作业3
//
//  Created by dllo on 16/7/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Book.h"
#import "BookManager.h"
int main(int argc, const char * argv[]) {
    @autoreleasepool {
       /** 截取字符串1. "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
        2.向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
        3.实现图书管理系统(BookManager类)：
        使用数组管理所有书籍(Book类)。
        BookManager类属性数组可以添加、删除。
        可以从数组根据书名查找书籍，并修改书籍的价格。
        展示所有书籍清单（书名）*/
        NSString *str = [NSString stringWithFormat:@"20|https://www.baidu.com"];
        NSArray *arr = [str componentsSeparatedByString:@"|"];
        NSString *str1 = [arr firstObject];
        NSString *str2 = [arr lastObject];
        NSLog(@"前面字符串%@,后面字符串%@",str1,str2);       
        
        NSMutableArray *arr1 = [NSMutableArray arrayWithObjects:[NSNumber numberWithInt:10], [NSNumber numberWithFloat:3.14],[NSNumber numberWithBool:YES], [NSNumber numberWithDouble:7.145], nil];
        NSLog(@"%@",arr1);
        
        Book *book1 = [Book bookWithBookName:@"钢铁是怎样炼成的" price:100];
        Book *book2 = [Book bookWithBookName:@"简爱" price:190];
        Book *book3 = [Book bookWithBookName:@"C#从入门到放弃" price:130];
        Book *book4 = [Book bookWithBookName:@"西方经济学" price:140];
        BookManager *bookManger = [[BookManager alloc] init];
        // BookManager属性数组管理所有书籍
        // 数组后面的逗号要空格
        bookManger.bookArr = [NSMutableArray arrayWithObjects:book1, book2, book3, book4, nil];
        [bookManger addBook:book4];
        [bookManger delBook:book3];        
        [bookManger checkName:@"简爱" price:180];
        [bookManger showBooks];
    }
    return 0;
}
